<cfparam default="" name="PageType" />

<cfoutput>
        
        <!---ServicePlanTargets, ElderDPNs, Provider is set in showreport--->           
        
        <style>
            .reportBorder{ border-left:1px solid ##29A5B7;border-top:1px solid ##29A5B7;}
            .reportBorderBottom{border-left:1px solid ##29A5B7;border-top:1px solid ##29A5B7;border-bottom:1px solid ##29A5B7;}
        </style>
        
        <cfif PageType EQ "XLS">
        
        	<!--- Set this HTTP Document as an Excel Spreadsheet --->
            <cfheader name="Content-Type:" value="application/vnd.ms-excel">
            <cfheader name="Content-Disposition:" value="attachment; filename=ServicePlanTargets_#url.DateFrom#_to_#url.DateTo#.xls">
            
            <!--- Output ONLY items enclosed in CF tags --->
            <cfsetting enablecfoutputonly="true">
        
            <table width="100%" cellpadding="0" cellspacing="0" style="font-size:10px">
                <thead>
                    <tr>
                        <th colspan="4">#Provider.ProviderFirstName# #Provider.ProviderLastName#</th>
                        <th colspan="4" class='reportBorder'>Telephoning</th>
                        <th colspan="3" class='reportBorder'>Home Visit</th>
                        <th colspan="3" class='reportBorder'>Group Visit</th>
                        <th colspan="3" class='reportBorder'>Chore</th>
                        <th colspan="3" class='reportBorder'>Meal Prep</th>
                    </tr>
                    <tr>
                        <th class='reportBorder'>Phone ##</th><th class='reportBorder'>Last Name</th><th class='reportBorder'>First Name</th><th class='reportBorder'>DOB</th>
                        <th class='reportBorder'>Date</th><th class='reportBorder'>Due</th><th class='reportBorder'>Actual</th>
                        <th class='reportBorder'>DNKA</th><th class='reportBorder'>Due</th><th class='reportBorder'>Actual</th>
                        <th class='reportBorder'>DNKA</th><th class='reportBorder'>Due</th><th class='reportBorder'>Actual</th>
                        <th class='reportBorder'>DNKA</th><th class='reportBorder'>Due</th><th class='reportBorder'>Actual</th>
                        <th class='reportBorder'>DNKA</th><th class='reportBorder'>Due</th><th class='reportBorder'>Actual</th>
                        <th class='reportBorder'>DNKA</th>
                    </tr>
                </thead>
                <tbody>
                
                    <cfset TelephoningDueTotal = 0 />
                    <cfset TelephoningActualTotal = 0 />
                    <cfset TelephoningDNKATotal = 0 />
                    <cfset HomeVisitDueTotal = 0 />
                    <cfset HomeVisitActualTotal = 0 />
                    <cfset HomeVisitDNKATotal = 0 />
                    <cfset GroupVisitDueTotal = 0 />
                    <cfset GroupVisitActualTotal = 0 />
                    <cfset GroupVisitDNKATotal = 0 />
                    <cfset ChoreDueTotal = 0 />
                    <cfset ChoreActualTotal = 0 />
                    <cfset ChoreDNKATotal = 0 />
                    <cfset MealPrepDueTotal = 0 />
                    <cfset MealPrepActualTotal = 0 />
                    <cfset MealPrepDNKATotal = 0 />
                    
                    <cfloop query="ServicePlanTargets" >
                        
                        <cfquery dbtype="query" name="qryDPNs">
                            SELECT *
                            FROM ElderDPNs
                            WHERE ElderListID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ServicePlanTargets.ElderListID#" />    
                        </cfquery>
                        
                        <tr>
                            <td class='reportBorder'>#ServicePlanTargets.HOMEPHONE#</td>
                            <td class='reportBorder'>
                                <a href="serviceplan.cfm?ElderID=#ServicePlanTargets.ElderListID#" >#ServicePlanTargets.LASTNAME#</a>
                            </td>
                            <td class='reportBorder'>
                                <a href="serviceplan.cfm?ElderID=#ServicePlanTargets.ElderListID#" >#ServicePlanTargets.FIRSTNAME#</a>
                            </td>
                            <td class='reportBorder'>#dateFormat(ServicePlanTargets.DOB, 'mm/dd/yyyy')#</td>
                            <td class='reportBorder'>#dateFormat(ServicePlanTargets.PlanDate, 'mm/dd/yyyy')#</td>
                            <td class='reportBorder'>
                                #ServicePlanTargets.TELEPHONING#
                                <cfset TelephoningDueTotal = TelephoningDueTotal + ServicePlanTargets.TELEPHONING />
                            </td>
                            <td class='reportBorder'>
                                <cfset DPNTelephoning = qryDPNs.TELEPHONING + elderDPNs.TELEPHONINGCOUNT />
                                #DPNTelephoning#
                                <cfset TelephoningActualTotal = TelephoningActualTotal + DPNTelephoning />
                            </td>
                            <td class='reportBorder'>
                            	#qryDPNs.DNKATELEPHONING#
                                <cfset TelephoningDNKATotal = TelephoningDNKATotal + qryDPNs.DNKATELEPHONING />
                            </td>
                            <td class='reportBorder'>
                                #ServicePlanTargets.HOMEVIST#
                                <cfset HomeVisitDueTotal = HomeVisitDueTotal + ServicePlanTargets.HOMEVIST />
                            </td>
                            <td class='reportBorder'>
                                #qryDPNs.INHOMEVISIT#
                                <cfset HomeVisitActualTotal = HomeVisitActualTotal + qryDPNs.INHOMEVISIT />
                            </td>
                            <td class='reportBorder'>
                                #qryDPNs.DNKAHOMEVISIT#
                                <cfset HomeVisitDNKATotal = HomeVisitDNKATotal + qryDPNs.DNKAHOMEVISIT />
                            </td>
                            <td class='reportBorder'>
                                #ServicePlanTargets.GROUPVISIT#
                                <cfset GroupVisitDueTotal = GroupVisitDueTotal + ServicePlanTargets.GROUPVISIT />
                            </td>
                            <td class='reportBorder'>
                                #qryDPNs.GROUPVISIT#
                                <cfset GroupVisitActualTotal = GroupVisitActualTotal + qryDPNs.GROUPVISIT />
                            </td>
                            <td class='reportBorder'>
                                #qryDPNs.DNKAGROUPVISIT#
                                <cfset GroupVisitDNKATotal = GroupVisitDNKATotal + qryDPNs.DNKAGROUPVISIT />
                            </td>
                            <td class='reportBorder'>
                                #ServicePlanTargets.LIGHTCHORE#
                                <cfset ChoreDueTotal = ChoreDueTotal + ServicePlanTargets.LIGHTCHORE />
                            </td>
                            <td class='reportBorder'>
                                #qryDPNs.CHORE#
                                <cfset ChoreActualTotal = ChoreActualTotal + qryDPNs.CHORE />
                            </td>
                            <td class='reportBorder'>
                            	#qryDPNs.DNKACHORE#
                                <cfset ChoreDNKATotal = ChoreDNKATotal + qryDPNs.DNKACHORE />
                            </td>
                            <td class='reportBorder'>                    
                                #ServicePlanTargets.MEALPREP#
                                <cfset MealPrepDueTotal = MealPrepDueTotal + ServicePlanTargets.MEALPREP />
                            </td>
                            <td class='reportBorder'>
                                #qryDPNs.LightMealPrep#
                                <cfset MealPrepActualTotal = MealPrepActualTotal + qryDPNs.LightMealPrep />
                            </td>
                            <td class='reportBorder'>
                            	#qryDPNs.DNKAMealPrep#
                                <cfset MealPrepDNKATotal = MealPrepDNKATotal + qryDPNs.DNKAMealPrep />
                            </td>
                        </tr>
                    </cfloop>
                    <tr>
                        <td colspan="5">&nbsp;</td>
                        <td class='reportBorderBottom'>#TelephoningDueTotal#</td>
                        <td class='reportBorderBottom'>#TelephoningActualTotal#</td>
                        <td class='reportBorderBottom'>#TelephoningDNKATotal#</td>
                        <td class='reportBorderBottom'>#HomeVisitDueTotal#</td>
                        <td class='reportBorderBottom'>#HomeVisitActualTotal#</td>
                        <td class='reportBorderBottom'>#HomeVisitDNKATotal#</td>
                        <td class='reportBorderBottom'>#GroupVisitDueTotal#</td>
                        <td class='reportBorderBottom'>#GroupVisitActualTotal#</td>
                        <td class='reportBorderBottom'>#GroupVisitDNKATotal#</td>
                        <td class='reportBorderBottom'>#ChoreDueTotal#</td>
                        <td class='reportBorderBottom'>#ChoreActualTotal#</td>
                        <td class='reportBorderBottom'>#ChoreDNKATotal#</td>
                        <td class='reportBorderBottom'>#MealPrepDueTotal#</td>
                        <td class='reportBorderBottom'>#MealPrepActualTotal#</td>
                        <td class='reportBorderBottom'>#MealPrepDNKATotal#</td>
                    </tr>
                </tbody>
            </table>
            
            </cfsetting>
        
        <cfelse>
        
			<!---HTML header, css links, js links, and page title--->
            #BASE.htmlHeader("", "css/style.css", "Elder's Program - Reports")#
            <!---HTML header, css links, js links, and page title--->
          
            <h2>Service Plan Targets</h2>
        
            <table width="100%" cellpadding="0" cellspacing="0" style="font-size:10px">
                <thead>
                    <tr>
                        <th colspan="4">#Provider.ProviderFirstName# #Provider.ProviderLastName#</th>
                        <th colspan="4" class='reportBorder' align="center">Telephoning</th>
                        <th colspan="3" class='reportBorder' align="center">Home Visit</th>
                        <th colspan="3" class='reportBorder' align="center">Group Visit</th>
                        <th colspan="3" class='reportBorder' align="center">Chore</th>
                        <th colspan="3" class='reportBorder' align="center">Meal Prep</th>
                    </tr>
                    <tr>
                        <th class='reportBorder'>Phone ##</th><th class='reportBorder'>Last Name</th><th class='reportBorder'>First Name</th><th class='reportBorder'>DOB</th>
                        <th class='reportBorder'>Date</th><th class='reportBorder'>Due</th><th class='reportBorder'>Actual</th>
                        <th class='reportBorder'>DNKA</th><th class='reportBorder'>Due</th><th class='reportBorder'>Actual</th>
                        <th class='reportBorder'>DNKA</th><th class='reportBorder'>Due</th><th class='reportBorder'>Actual</th>
                        <th class='reportBorder'>DNKA</th><th class='reportBorder'>Due</th><th class='reportBorder'>Actual</th>
                        <th class='reportBorder'>DNKA</th><th class='reportBorder'>Due</th><th class='reportBorder'>Actual</th>
                        <th class='reportBorder'>DNKA</th>
                    </tr>
                </thead>
                <tbody>
                
                    <cfset TelephoningDueTotal = 0 />
                    <cfset TelephoningActualTotal = 0 />
                    <cfset TelephoningDNKATotal = 0 />
                    <cfset HomeVisitDueTotal = 0 />
                    <cfset HomeVisitActualTotal = 0 />
                    <cfset HomeVisitDNKATotal = 0 />
                    <cfset GroupVisitDueTotal = 0 />
                    <cfset GroupVisitActualTotal = 0 />
                    <cfset GroupVisitDNKATotal = 0 />
                    <cfset ChoreDueTotal = 0 />
                    <cfset ChoreActualTotal = 0 />
                    <cfset ChoreDNKATotal = 0 />
                    <cfset MealPrepDueTotal = 0 />
                    <cfset MealPrepActualTotal = 0 />
                    <cfset MealPrepDNKATotal = 0 />
                    
                    <cfloop query="ServicePlanTargets" >
                        
                        <cfquery dbtype="query" name="qryDPNs">
                            SELECT *
                            FROM ElderDPNs
                            WHERE ElderListID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ServicePlanTargets.ElderListID#" />    
                        </cfquery>
                        
                        <tr>
                            <td class='reportBorder'>#ServicePlanTargets.HOMEPHONE#</td>
                            <td class='reportBorder'>
                                <a href="serviceplan.cfm?ElderID=#ServicePlanTargets.ElderListID#" >#ServicePlanTargets.LASTNAME#</a>
                            </td>
                            <td class='reportBorder'>
                                <a href="serviceplan.cfm?ElderID=#ServicePlanTargets.ElderListID#" >#ServicePlanTargets.FIRSTNAME#</a>
                            </td>
                            <td class='reportBorder'>#dateFormat(ServicePlanTargets.DOB, 'mm/dd/yyyy')#</td>
                            <td class='reportBorder'>#dateFormat(ServicePlanTargets.PlanDate, 'mm/dd/yyyy')#</td>
                            <td class='reportBorder'>
                                #ServicePlanTargets.TELEPHONING#
                                <cfset TelephoningDueTotal = TelephoningDueTotal + ServicePlanTargets.TELEPHONING />
                            </td>
                            <td class='reportBorder'>
                                <cfset DPNTelephoning = val(qryDPNs.TELEPHONING) + val(elderDPNs.TELEPHONINGCOUNT) />
                                #DPNTelephoning#
                                <cfset TelephoningActualTotal = val(TelephoningActualTotal) + val(DPNTelephoning) />
                            </td>
                            <td class='reportBorder'>
                            	#qryDPNs.DNKATELEPHONING#
                                <cfset TelephoningDNKATotal = TelephoningDNKATotal + qryDPNs.DNKATELEPHONING />
                            </td>
                            <td class='reportBorder'>
                                #ServicePlanTargets.HOMEVIST#
                                <cfset HomeVisitDueTotal = HomeVisitDueTotal + ServicePlanTargets.HOMEVIST />
                            </td>
                            <td class='reportBorder'>
                                #qryDPNs.INHOMEVISIT#
                                <cfset HomeVisitActualTotal = HomeVisitActualTotal + qryDPNs.INHOMEVISIT />
                            </td>
                            <td class='reportBorder'>
                                #qryDPNs.DNKAHOMEVISIT#
                                <cfset HomeVisitDNKATotal = HomeVisitDNKATotal + qryDPNs.DNKAHOMEVISIT />
                            </td>
                            <td class='reportBorder'>
                                #ServicePlanTargets.GROUPVISIT#
                                <cfset GroupVisitDueTotal = GroupVisitDueTotal + ServicePlanTargets.GROUPVISIT />
                            </td>
                            <td class='reportBorder'>
                                #qryDPNs.GROUPVISIT#
                                <cfset GroupVisitActualTotal = GroupVisitActualTotal + qryDPNs.GROUPVISIT />
                            </td>
                            <td class='reportBorder'>
                                #qryDPNs.DNKAGROUPVISIT#
                                <cfset GroupVisitDNKATotal = GroupVisitDNKATotal + qryDPNs.DNKAGROUPVISIT />
                            </td>
                            <td class='reportBorder'>
                                #ServicePlanTargets.LIGHTCHORE#
                                <cfset ChoreDueTotal = ChoreDueTotal + ServicePlanTargets.LIGHTCHORE />
                            </td>
                            <td class='reportBorder'>
                                #qryDPNs.CHORE#
                                <cfset ChoreActualTotal = ChoreActualTotal + qryDPNs.CHORE />
                            </td>
                            <td class='reportBorder'>
                            	#qryDPNs.DNKACHORE#
                                <cfset ChoreDNKATotal = ChoreDNKATotal + qryDPNs.DNKACHORE />
                            </td>
                            <td class='reportBorder'>                    
                                #ServicePlanTargets.MEALPREP#
                                <cfset MealPrepDueTotal = MealPrepDueTotal + ServicePlanTargets.MEALPREP />
                            </td>
                            <td class='reportBorder'>
                                #qryDPNs.LightMealPrep#
                                <cfset MealPrepActualTotal = MealPrepActualTotal + qryDPNs.LightMealPrep />
                            </td>
                            <td class='reportBorder'>
                            	#qryDPNs.DNKAMealPrep#
                                <cfset MealPrepDNKATotal = MealPrepDNKATotal + qryDPNs.DNKAMealPrep />
                            </td>
                        </tr>
                    </cfloop>
                    <tr>
                        <td colspan="5">&nbsp;</td>
                        <td class='reportBorderBottom'>#TelephoningDueTotal#</td>
                        <td class='reportBorderBottom'>#TelephoningActualTotal#</td>
                        <td class='reportBorderBottom'>#TelephoningDNKATotal#</td>
                        <td class='reportBorderBottom'>#HomeVisitDueTotal#</td>
                        <td class='reportBorderBottom'>#HomeVisitActualTotal#</td>
                        <td class='reportBorderBottom'>#HomeVisitDNKATotal#</td>
                        <td class='reportBorderBottom'>#GroupVisitDueTotal#</td>
                        <td class='reportBorderBottom'>#GroupVisitActualTotal#</td>
                        <td class='reportBorderBottom'>#GroupVisitDNKATotal#</td>
                        <td class='reportBorderBottom'>#ChoreDueTotal#</td>
                        <td class='reportBorderBottom'>#ChoreActualTotal#</td>
                        <td class='reportBorderBottom'>#ChoreDNKATotal#</td>
                        <td class='reportBorderBottom'>#MealPrepDueTotal#</td>
                        <td class='reportBorderBottom'>#MealPrepActualTotal#</td>
                        <td class='reportBorderBottom'>#MealPrepDNKATotal#</td>
                    </tr>
                </tbody>
            </table>
            
         	<!---HTML footer, closes html and body tags.  Any footer info goes here--->
    		#BASE.htmlFooter()#
    		<!---HTML footer, closes html and body tags.  Any footer info goes here--->  	
        
        </cfif>
        

</cfoutput>